package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.DoctorTitleDictMapper;
import com.ghck.server.model.DoctorTitleDict;
import com.ghck.server.model.query.DoctorTitleDictQuery;
import com.ghck.server.service.DoctorTitleDictService;

/**
 * 医生职称头衔  <br>
 * dict_doctor_title <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class DoctorTitleDictServiceImpl implements DoctorTitleDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(DoctorTitleDictServiceImpl.class);
	
	@Autowired
	private DoctorTitleDictMapper doctorTitleDictMapper;
	
	/**
 	*根据ID删除 医生职称头衔
 	*/
 	@Override
 	public Integer deleteDoctorTitleDictById(Integer id){
 		return doctorTitleDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 医生职称头衔
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertDoctorTitleDict(List<? extends DoctorTitleDict> doctorTitleDicts){
		Integer count = doctorTitleDictMapper.batchInsert(doctorTitleDicts);
		return count;
 	}
 	/**
 	*新增 医生职称头衔
 	*/
 	@Override
 	@Transactional
 	public Integer insertDoctorTitleDict(DoctorTitleDict domain){
		Integer id = doctorTitleDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 医生职称头衔
 	*/
 	@Override
 	@Transactional
 	public Integer updateDoctorTitleDict(DoctorTitleDict domain){
		Integer count = doctorTitleDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 医生职称头衔
 	*/
 	public DoctorTitleDict findDoctorTitleDictById(Integer id){
 		DoctorTitleDict result = doctorTitleDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 医生职称头衔
 	*/
	public List<DoctorTitleDict> findDoctorTitleDictByQuery(DoctorTitleDictQuery query){
		query.dealWith();
		List<DoctorTitleDict> result = doctorTitleDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (DoctorTitleDict doctorTitleDict : result) {
				doctorTitleDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countDoctorTitleDictByQuery(DoctorTitleDictQuery query){
 		query.dealWith();
 		Integer result = doctorTitleDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<DoctorTitleDict> findDoctorTitleDictByIds(List<Integer> ids){
 		List<DoctorTitleDict> result = doctorTitleDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (DoctorTitleDict doctorTitleDict : result) {
				doctorTitleDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public DoctorTitleDict findByName(String name){
		DoctorTitleDict result = doctorTitleDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<DoctorTitleDict> findAll(){
		List<DoctorTitleDict> result = doctorTitleDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (DoctorTitleDict doctorTitleDict : result) {
				doctorTitleDict.dealWith();
			}
		}
		return result;
	}
}	